home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / html / util / genskunk.new < prev    next >
Text File  |  1997-08-19  |  10KB  |  403 lines

  1. #! /usr/bin/perl -w 
  2.  
  3. $0 =~ s,.*/,,;
  4. $version="v1.1";
  5. $program=$0;
  6. $debug=0;
  7. $mailto='mailto:skunkware@sco.com';
  8. $baseref='http://hyperion.pdev.sco.com/skunkware';
  9. $isweb=0;
  10.  
  11. sub usage {
  12.   warn "@_\n" if @_;
  13.   $! = 0;
  14.   die <<EOF;
  15. Usage: $0 -w | -c file name prev next
  16.   -w        - Generate pages for the Web
  17.   -c        - Generate pages for the CD-ROM
  18.   file      - name of the template (.tmpl) file
  19.   name      - the name of the package
  20.   prev      - the name of the previous link
  21.   next      - the name of the next link
  22.  
  23.   Use the word NONE for the prev and next parameters if the page doesnt
  24.   have a previous or next page in the document chain.
  25.  
  26. EOF
  27. }
  28.  
  29. if (@ARGV<1 || $#ARGV != 4) {
  30.   usage();
  31. }
  32.  
  33. $mode="0";
  34.  
  35. if($ARGV[0] eq "-w" || $ARGV[0] eq "web") {
  36.   $mode="SKUNK_WEB";
  37.   $isweb=1;
  38. }
  39. elsif($ARGV[0] eq "-c" || $ARGV[0] eq "cd") {
  40.   $mode="SKUNK_CD";
  41. }
  42.  
  43. if ($mode eq "0") {
  44.   usage();
  45. }
  46.  
  47. $now=`date '+%A %b %d, %Y at %T %Z'`; chop $now;
  48. $basefile=$ARGV[1];
  49. $shortname=$ARGV[2];
  50. $previous=$ARGV[3];
  51. $next=$ARGV[4];
  52. $realbase=`basename $basefile`; chop $realbase;
  53. #if ($isweb) {
  54. #  if (not -d $shortname) {
  55. #    mkdir($shortname,0755) or die "$program error: Could not create directory $shortname\n";
  56. #  }
  57. #  $output="$shortname/index.html";
  58. #} else {
  59.   $output="${realbase}.html";
  60. #}
  61. $template="${basefile}.tmpl";
  62. $templflt="/lib/cpp -I. -I.. -I../src -D$mode $template |";
  63.  
  64. -f $template or die "$program error: $template not found\n";
  65.  
  66. if ($debug) {
  67.  print "basefile : $basefile\n";
  68.  print "now      : $now\n";
  69.  print "shortname: $shortname\n";
  70.  print "previous : $previous\n";
  71.  print "next     : $next\n";
  72.  print "output   : $output\n";
  73.  print "realbase : $realbase\n";
  74.  print "template : $template\n";
  75. }
  76.  
  77. if ($previous eq "none" or $previous eq "NONE")
  78. {
  79.     $prevref="";
  80. } else {
  81.     if ($isweb) {
  82.         $prevref="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$previous/index.html\">";
  83.     } else {
  84.         $prevref="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$previous.html\">";
  85.     }
  86. }
  87.  
  88. if ($next eq "none" or $next eq "NONE") {
  89.     $nextref="";
  90. } else {
  91.     if ($isweb) {
  92.         $nextref="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$next/index.html\">";
  93.     } else {
  94.         $nextref="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$next.html\">";
  95.     }
  96. }
  97.  
  98. if ($debug) {
  99.  print "nextref=$nextref\n";
  100.  print "prevref=$prevref\n";
  101. }
  102.  
  103. open (TEMPLATE,$templflt) or die "$program error: cannot open $template for reading\n";
  104. open (OUTPUT,">$output") or die "$program error: cannot open $output for output\n";
  105.  
  106. sub skunkheader{
  107.     my($foo) = @_;
  108.     my($title,$plink,$nlink) = split(/;/,$foo);
  109.     my($oplink,$onlink);
  110.     if (not $plink) {
  111.         $oplink = $prevref;
  112.     } else {
  113.         if ($isweb) {
  114.             $oplink="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$plink/index.html\">";
  115.         } else {
  116.             $oplink="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$plink.html\">";
  117.         }
  118.     }
  119.     if (not $nlink) {
  120.         $onlink = $nextref;
  121.     } else {
  122.         if ($isweb) {
  123.             $onlink="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$nlink/index.html\">";
  124.         } else {
  125.             $onlink="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$nlink.html\">";
  126.         }
  127.     }
  128.  
  129.     if ($debug) {
  130.         print "skunkheader: title='$title'\n";
  131.         print "             oplink='$oplink'\n";
  132.         print "             onlink='$onlink'\n";
  133.     }
  134.  
  135.     if (not $title) {
  136.         warn "$program: No TITLE specified in SKUNKHEADER\n";
  137.     }
  138.  
  139.     if (not $isweb) {
  140. #
  141. # This is the header information for the Skunkware CD-ROM
  142. #
  143.         print OUTPUT <<EOF;
  144. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  145. <!-- DO NOT EDIT -->
  146. <!-- Automatically generated from $template by $program $version -->
  147. <!-- DO NOT EDIT -->
  148. <HTML>
  149. <HEAD>
  150.   <TITLE>$title</TITLE>
  151.   <LINK REV="made" HREF="$mailto">
  152. </HEAD>
  153. <BODY BGCOLOR="#ffffff">
  154.  
  155. <MAP NAME="skunknav">
  156.   <AREA SHAPE="rect" COORDS="347,1,460,26" HREF="$baseref/$shortname">
  157.   $oplink
  158.   $onlink
  159.   <AREA SHAPE="rect" COORDS="3,1,93,26" HREF="index.html">
  160. </MAP>
  161.  
  162. <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" BORDER="0">
  163.   <TR ALIGN="LEFT" VALIGN="TOP">
  164.     <TD ROWSPAN="2" WIDTH="20%">
  165.       <IMG SRC="gif/sk97s.gif" HEIGHT="104" WIDTH="108" ALIGN="BOTTOM">
  166.     </TD>
  167.     <TD VALIGN="BOTTOM" WIDTH="79%">
  168.       <IMG ISMAP USEMAP="#skunknav" SRC="gif/skunknav.gif" HEIGHT="26"
  169.           WIDTH="466" ALIGN="BOTTOM" BORDER="0">
  170.     </TD>
  171.   </TR>
  172.   <TR>
  173.     <TD VALIGN="TOP">
  174.       <IMG SRC="gif/${shortname}.gif" HEIGHT="26" ALIGN="BOTTOM">
  175.     </TD>
  176.   </TR>
  177. </TABLE>
  178.  
  179. <H2 ALIGN="CENTER">Last Updated: $now</H2>
  180. EOF
  181.   } else {
  182. #
  183. # This is the header information for the Skunkware On-line pages
  184. #
  185.     print OUTPUT <<EOF;
  186. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  187. <!-- DO NOT EDIT -->
  188. <!-- Automatically generated from $template by $program $version -->
  189. <!-- DO NOT EDIT -->
  190. <HTML>
  191. <HEAD>
  192.   <TITLE>$title</TITLE>
  193.   <LINK REV="made" HREF="$mailto">
  194. </HEAD>
  195. <BODY BGCOLOR="#ffffff">
  196.  
  197. <MAP NAME="skunknav">
  198.   <AREA SHAPE="rect" COORDS="347,1,460,26" HREF="$baseref/$shortname">
  199.   $oplink
  200.   $onlink
  201.   <AREA SHAPE="rect" COORDS="3,1,93,26" HREF="index.html">
  202. </MAP>
  203.  
  204. <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" BORDER="0">
  205.   <TR ALIGN="LEFT" VALIGN="TOP">
  206.     <TD ROWSPAN="2" WIDTH="20%">
  207.       <IMG SRC="gif/sk97s.gif" HEIGHT="104" WIDTH="108" ALIGN="BOTTOM">
  208.     </TD>
  209.     <TD VALIGN="BOTTOM" WIDTH="79%">
  210.       <IMG ISMAP USEMAP="#skunknav" SRC="gif/skunknav.gif" HEIGHT="26"
  211.           WIDTH="466" ALIGN="BOTTOM" BORDER="0">
  212.     </TD>
  213.   </TR>
  214.   <TR>
  215.     <TD VALIGN="TOP">
  216.       <IMG SRC="gif/${shortname}.gif" HEIGHT="26" ALIGN="BOTTOM">
  217.     </TD>
  218.   </TR>
  219. </TABLE>
  220.  
  221. <H2 ALIGN="CENTER">Last Updated: $now</H2>
  222. EOF
  223.   }
  224. }
  225.  
  226. sub skunkfooter {
  227.     my($foo) = @_;
  228.  
  229.     if ($isweb) {
  230. #
  231. # Print out the footer of a page for the On-line version of the page.
  232. # This should conform to the corporate guidelines.
  233. #
  234.         print OUTPUT <<EOF;
  235. <P><HR ALIGN=LEFT>
  236. <P> <FONT SIZE=-2>
  237. © Copyright 1997 The Santa Cruz Operation, Inc. All rights reserved.
  238. </FONT>
  239. </BODY>
  240. </HTML>
  241. EOF
  242.     } else {
  243. #
  244. # Print out the fotter for the CD-ROM version.
  245. #
  246.         print OUTPUT <<EOF;
  247. <P><HR ALIGN=LEFT>
  248. <P> <FONT SIZE=-2>
  249. © Copyright 1997 The Santa Cruz Operation, Inc. All rights reserved.
  250. </FONT>
  251. </BODY>
  252. </HTML>
  253. EOF
  254.     }
  255. }
  256.  
  257. sub start_packagelist {
  258.     my($foo) = @_;
  259.  
  260.     print OUTPUT <<EOF;
  261. <H2 ALIGN="CENTER">Package List</H2>
  262. <CENTER><TABLE WIDTH="100%" BORDER="1" CELLSPACING="0" CELLPADDING="2">
  263.   <TR>
  264.     <TH WIDTH="11%" HEIGHT="23">Name</TH>
  265.     <TH WIDTH="62%">Description</TH>
  266.     <TH WIDTH="9%">Version</TH>
  267.     <TH WIDTH="7%">OSR5</TH>
  268.     <TH WIDTH="11%">UnixWare</TH>
  269.   </TR>
  270. EOF
  271. }
  272.  
  273. sub end_packagelist {
  274.     my($foo) = @_;
  275.  
  276.     print OUTPUT <<EOF;
  277. </TABLE></CENTER>
  278. <H4><HR ALIGN="LEFT"></H4>
  279. EOF
  280. }
  281.  
  282. sub startpack {
  283.     my($linkref,$desc) = @_;
  284.     print OUTPUT <<EOF;
  285. <H4><A NAME="$linkref"></A>$desc</H4>
  286. <BLOCKQUOTE>
  287. EOF
  288. }
  289.  
  290. sub endpack {
  291.     my($foo) = @_;
  292.  
  293.     print OUTPUT <<EOF;
  294. </BLOCKQUOTE>
  295. <P> </P>
  296. EOF
  297. }
  298.  
  299. sub source {
  300.     my($site) = @_;
  301.  
  302.     print OUTPUT <<EOF;
  303. <P>
  304. <A HREF="$site">
  305.   <IMG SRC="gif/origsrc.gif" ALT="Original source code" HSPACE="20" BORDER="0"
  306.             HEIGHT="32" WIDTH="160" ALIGN="CENTER"></A>
  307. <A HREF="$site">$site</A></P>
  308. EOF
  309. }
  310.  
  311. sub homepage {
  312.     my($page) = @_;
  313.  
  314.     print OUTPUT <<EOF;
  315. <P>
  316. <A HREF="$page">
  317.   <IMG SRC="gif/homepage.gif" ALT="Package Home page" HSPACE="20" BORDER="0"
  318.             HEIGHT="32" WIDTH="160" ALIGN="CENTER"></A>
  319. <A HREF="$page">$page</A></P>
  320. EOF
  321. }
  322.  
  323. sub osr5dist {
  324.     my($location) = @_;
  325.     my($volfile);
  326.     if ($location =~ /osr5\//) {
  327.         if (not $location =~ /\/$/) {
  328.             $location = "$location/";
  329.         }
  330.         $volfile="${location}VOLS.tar";
  331.         print OUTPUT <<EOF;
  332. <P><A HREF="$baseref/$volfile">
  333.   <IMG SRC="gif/osr5dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  334.   ALIGN="CENTER" ALT="OpenServer Distribution"></A>
  335. <A HREF="$baseref/$location">$location</A></P>
  336. EOF
  337.     } else {
  338.         print OUTPUT <<EOF;
  339. <P><A HREF="$location">
  340.   <IMG SRC="gif/osr5dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  341.   ALIGN="CENTER" ALT="OpenServer Distribution">
  342. $location
  343. </A></P>
  344. EOF
  345.     }
  346. }
  347.  
  348. sub uw2dist {
  349.     my($location) = @_;
  350.     my($volfile);
  351.     if ($location =~ /uw2\//) {
  352.         if (not $location =~ /\/$/) {
  353.             $location = "$location/";
  354.         }
  355.         print OUTPUT <<EOF;
  356. <P><A HREF="$baseref/$location">
  357.   <IMG SRC="gif/uw2dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  358.   ALIGN="CENTER" ALT="UnixWare Distribution"></A>
  359. <A HREF="$baseref/$location">$location</A></P>
  360. EOF
  361.     } else {
  362.         print OUTPUT <<EOF;
  363. <P><A HREF="$location">
  364.   <IMG SRC="gif/uw2dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  365.   ALIGN="CENTER" ALT="UnixWare Distribution">
  366. $location
  367. </A></P>
  368. EOF
  369.     }
  370. }
  371.  
  372. sub packlist{
  373.     my($foo) = @_;
  374.     my($linkref,$desc,$packver,$isosr5,$isuw2) = split(/;/, $foo);
  375.  
  376.     print OUTPUT <<EOF;
  377. <TR>
  378.   <TD><A HREF="#$linkref">$linkref</A></TD>
  379.   <TD>$desc</TD>
  380.   <TD>$packver</TD>
  381.   <TD ALIGN="CENTER">$isosr5</TD>
  382.   <TD ALIGN="CENTER">$isuw2</TD>
  383. </TR>
  384. EOF
  385. }
  386.  
  387. LINE: while (defined($line = <TEMPLATE>)) {
  388.     next LINE if $line =~ /^# [0-9]* \"/;
  389.     chop $line;
  390.     if ($line =~ s/@@\@SKUNKHEADER\((.*)\)//) { skunkheader($1);}
  391.     elsif ($line =~ s/@@\@SKUNKFOOTER//) { skunkfooter();}
  392.     elsif ($line =~ s/@@\@START_PACKAGELIST//) {start_packagelist();}
  393.     elsif ($line =~ s/@@\@END_PACKAGELIST//) {end_packagelist();}
  394.     elsif ($line =~ s/@@\@STARTPACK\((.*);(.*)\)//) {startpack($1,$2);}
  395.     elsif ($line =~ s/@@\@ENDPACK//) {endpack();}
  396.     elsif ($line =~ s/@@\@OSR5DIST\((.*)\)//) {osr5dist($1);}
  397.     elsif ($line =~ s/@@\@UW2DIST\((.*)\)//) {uw2dist($1);}
  398.     elsif ($line =~ s/@@\@SOURCE\((.*)\)//) {source($1);}
  399.     elsif ($line =~ s/@@\@HOMEPAGE\((.*)\)//) {homepage($1);}
  400.     elsif ($line =~ s/@@\@PACKLIST\((.*)\)//) {packlist($1);}
  401.     else {print OUTPUT "$line\n";}
  402. }
  403.